<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>引出生命周期-原生js写法</title>
    <script type="text/javascript" src="../../js/vue.js"></script>
</head>
<body>
    <!--mounted函数：vue完成模版的解析并把初始的真实的dom元素挂载完毕就调用mounted函数，注意只在第一次dom元素挂在到页面后调用-->

    <div id = "root">
        <span v-bind:style = "{opacity:opacity}">欢迎学习VUE</span>
    </div>

    <script type="text/javascript">
        const vm = new Vue({
            el:"#root",
            data:function(){
                return {
                    opacity:1
                }
            }
        })
    //通过外部的定时器实现，不推荐
    setInterval(()=>{
        vm.opacity -= 0.01;
        if(vm.opacity <= 0) vm.opacity=1;
    },16)
    </script>
   
    
</body>
</html>